<?php
namespace App\Http\Controllers;

use App\Models\Monitor;
use Illuminate\Support\Facades\Schema;

class MonitorController extends WxBaseController{
    protected $except=['index','show'];
    public function index($num=10,$order='created_at'){
        $monitors = Monitor::orderBy($order,'desc')->simplePaginate($num);
        editImageUrl($monitors);
        return $this->apiReturn(true,'success',$monitors);
    }
    public function show($id){
        $monitor = Monitor::where('id',$id);
        //更新浏览量
        if(Schema::hasColumn('monitors', 'watch')){
            $monitor->increment('watch');
        };
        $arr=$monitor->get();
        editImageUrl($arr);
        return $this->apiReturn(true,'success',$arr);
    }
}